package demo;

import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import java.util.Random;
//�����
public class Fish extends coordinate{
	int step;//�ٶ�
	BufferedImage image;
	int index;
	Random ran=new Random();
	public  Fish(String name) throws Exception {
		//ͼƬ��ʼ��
		image=ImageIO.read(new File("fish00_00.png"));//���ͼƬ4
		w=image.getWidth();//��ȡͼƬ�Ŀ��
		h=image.getHeight();//��ȡ�߶�
		x=ran.nextInt(850-w);//�������0-800-w֮���ֵ
		y=ran.nextInt(600-h);//�������0-500-h֮���ֵ
		step=5;
			
	}
	public void move() {
		x=x-step;
		if(x<-w){
			getOut();
		}
	}
	public void getOut() {//�����������
		x=850;
		y=ran.nextInt(600-h);
		step=2+ran.nextInt(5);
	}
}
